Affective computing service protocol
Relying on bio-data analysis services, we provide services such as attention, relaxation, and pressure value calculation.
The service requires our authorization before it can be used.
Service | Operation | Remarks |
---|---|---|
affective | start | starts, initializes the affective computing service |
subscribe | subscribe to real-time affective computing data | |
unsubscribe | unsubscribe to real-time affective computing data | |
report | Get a report on the current affective computing cloud service | |
finish | finish a cloud service |
Affective Start
Starts the Affective Cloud Computing service.
Request
{
"services": "affective",
"op": "start",
"kwargs": {
"cloud_services": [
cloud_service1, # attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}
Request Example
{
"services": "affective",
"op": "start",
"kwargs": {
"cloud_services": [
"attention",
"sleep"
]
}
}
Response
{
"code": 0,
"request": {
"services": "affective",
"op": "start"
},
"data": {
"cloud_service": [
cloud_service1, # The type of cloud service that has been started
cloud_serviceN
]
}
}
Affective Subscribe
Subscribe to the Affective Cloud Service real-time data. The analysis return value is an optional service. If you need to receive the value returned by the analysis in real time, enable this subscription and configure the parameters to be returned. See the following table for the specific parameters.
Subscribe has two types of Responses:
- Subscribe Success Response
- Subscribe Data Response
Subscribe Request structure
{
"services": "affective",
"op": "subscribe",
"args": [affective_service_type1, affective_service_type2] # Affective computing service type
}
Request Example
{
"services": "effective",
"op": "subscribe",
"args": ["attention", "sleep"]
}
Subscribe structure
Subscription Status Response The status return value of a successful subscription. Will return all computing services that are subscribed to.
{
"code": 0,
"request": {
"services": "affective",
"op": "subscribe"
},
"data": {
"sub_" + cloud_service1 + "_fields": [ # cloud_service1: cloud service type, attention, relaxation, pressure, etc.
data_type1, data_typeN, # subscribed data, see affective cloud service parameter column for details
]
"sub_" + cloud_serviceN + "_fields": [
data_type1, data_typeN,
]
}
}
Subscription Data Response
The data returned depends on the data set at the time of Affective Subscribe.
Affective cloud computing returns data service and parameter items in real time
cloud_service | data_type | type | value range | description |
---|---|---|---|---|
attention | attention | float | [0, 100] | Attention value, higher value means higher attention |
relaxation | relaxation | float | [0, 100] | The relaxation value, with higher values indicating higher relaxation |
pressure | pressure | float | [0, 100] | The value of pressure level, with higher values indicating higher levels of pressure |
arousal | arousal | float | [0, 100] | The value of activation, with higher values indicating higher affective activation |
sleep | sleep_degree | float | [0, 100] | The degree of sleep, with smaller values indicating deeper sleep. |
sleep_state | int | {0, 1} | The sleep state, 0 means not asleep, 1 means asleep |
{
"code": 0,
"request": {
"services": "affective",
"op": "subscribe"
},
"data": {
cloud_service1: { # Cloud service data type, attention, relaxation, pressure, etc.
data_type1: data1, # Data type, packet, see the Affective Cloud Service data table for details
data_typeN: dataN,
},
cloud_serviceN: {
data_type1: data1,
data_typeN: dataN,
}
}
}
}
Affective Unsubscribe
Unsubscribe from the Affective Cloud Service real-time data.
Unsubscribe Request structure
{
"services": "affective",
"op": "unsubscribe",
"args": [affective_service_type]
}
Request Example
{
"services": "affective",
"op": "unsubscribe",
"args": ["attention"]
}
Unsubscribe Response structure
{
"code": 0,
"request": {
"services": "affective",
"op": "unsubscribe"
},
"data": {
"sub_" + cloud_service1 + "_fields": [ # cloud_service1: cloud service data type, attention, relaxation, pressure, etc.
data_type1, data_typeN, # subscribed data, see the affective cloud service data table parameter column for details
]
"sub_" + cloud_serviceN + "_fields": [
data_type1, data_typeN,
]
}
}
Affective Report
After the number of packets returned by the subscription service has reached the required number, you can request a service data report. The report returns an analysis of all values from the start of the service to the execution of the operation. The specific report results that can be returned are shown in the following table.
Report call interval
- The report can be requested only after the number of packets returned by the subscription service has reached the required number, otherwise the return value is null or 0.
- Each requested Report is cached for 2 minutes, and the Report requested within 2 minutes is the result of the previous analysis. 2 minutes later, the cache expires, we will clear the Report data in the cache, and the new full Report data report is returned when requested again.
- Test application report retention time is 1 minute.
Category | Number of packets to be received | Request interval |
---|---|---|
attention | 5 | 2min |
relaxation | 5 | 2min |
pressure | 5 | 2min |
arousal | 5 | 2min |
pleasure | 5 | 2min |
sleep | coherence | 2min |
sleep | 5 | 3min |
Affective cloud computing service data report
category | parameters | type | value range | description |
---|---|---|---|---|
attention | attention_avg | float | [0, 100] | attention_average |
relaxation | relaxation_avg | float | [0, 100] | relaxation_average |
relaxation_rec | list[float] | [0, 100]*k, (k≥5) | Relaxation is recorded at 0.6x second intervals. | |
pressure | pressure_avg | float | [0, 100] | average pressure level |
pressure_rec | list[float] | [0, 100]*k, (k≥5) | Pressure level is recorded in full, with an interval of 0.6x seconds between points | |
arousal | arousal_avg | float | [0, 100] | activation_average |
arousal_rec | list[float] | [0, 100]*k, (k≥5) | The full record of the activation level, with 0.6x seconds between points | |
coherence_avg float | [0, 100] | mean of coherence | ||
coherence_rec | list[float] | [0, 100]*k, (k≥5) | coherence is recorded in full, with 0.6x seconds between points | |
sleep | sleep_curve | list[float] | [0, 100]*k, (k≥5) | Sleep curve with 0.6x (x≥10; the default conversion is 10 for session settings with x less than 10) a point. The degree of sleep is continuously depicted throughout the nap. The smaller the value means closer to deep sleep; the larger the value means closer to wakefulness |
sleep_point | int | [0, +∞) | The index of the sleep point timeline, used to mark the sleep point. The subscript of the corresponding sleep curve array, indicating which data point the user fell asleep. | |
sleep_latency | int | [0, +∞) | Sleep time, in seconds. | |
awake_duration | int | [0, +∞) | The duration of awakening, in seconds. | |
light_duration | int | [0, +∞) | Length of light sleep, in seconds | |
deep_duration | int | [0, +∞) | Deep_duration, in seconds |
Report Request structure
{
"services": "affective",
"op": "report",
"kwargs": {
"cloud_services": [
cloud_service1, # Cloud service data type, attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}
Request Example
{
"services": "effective",
"op": "report",
"kwargs": {
"cloud_services": [
"attention"
]
}
}
Report Response structure
{
"code": 0,
"request": {
"services": "affective",
"op": "report"
},
"data": {
cloud_service1: { #bio-data types, attention, relaxation, pressure, etc.
data_type1: data1, # data_type, packet See Sentiment cloud service data report for details
data_typeN: dataN,
},
cloud_serviceN: {
data_type1: data1,
data_typeN: dataN,
}
}
}
Affective Finish
Finish an Affective Cloud service.
- You need to request
finish
when the service runs out, if not, we will assume the service is not stopped. - The
finish
of the service will be requested automatically at the end of the session, but it is not recommended to usesession close
to end the service, you should finish the service first and then close the session.
Finish Request structure
{
"services": "affective",
"op": "finish",
"kwargs": {
"cloud_services": [
cloud_service1, # bio-data type, attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}
Request Example
{
"services": "affective",
"op": "finish",
"kwargs": {
"cloud_services": [
"attention"
]
}
}
Finish Response structure
{
"code": 0,
"request": {
"services": "affective",
"op": "finish"
},
"data": {
"cloud_service": [
cloud_service1, # attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}